<?php
/**
 * Created by PhpStorm.
 * User: Zbing
 * Date: 2016/12/23
 * Time: 1:34
 */

use GuzzleHttp\Client;

include_once "../vendor/autoload.php";

$client = new Client();

#$uri = 's?ie=utf-8&f=8&rsv_bp=0&rsv_idx=1&tn=baidu&wd=sohu&rsv_pq=d2a015f4000106da&rsv_t=aa3aTueLrJ%2F7Fz5EqVnU%2BUt4fEQEbECROKQXzTpEfXltmsNdkfeyllaXCnw&rqlang=cn&rsv_enter=1&rsv_sug3=5&rsv_sug1=4&rsv_sug7=100&rsv_sug2=0&inputT=1199&rsv_sug4=2238';

$uri = 'http://www.sohu.com';

//$request = $client->request('GET', $uri, ['verify' => false]);
$request = $client->get('http://www.zbing.net');
//$request->then(
//    function (\Psr\Http\Message\ResponseInterface $res) {
//        echo $res->getStatusCode() . "<br />";
//    },
//    function (\GuzzleHttp\Exception\RequestException $e) {
//        echo $e->getMessage() . "<br />";
//        echo $e->getRequest()->getMethod();
//    }
//);
//var_dump($request->getBody());
#var_dump($request);
//echo $request->getBody();
$contents = $request->getBody()->getContents();
//$as = (string) $body;
//var_dump($as);
//$sd = $body->read(1000);
//var_dump($sd);
//$as = $body->getContents();
//var_dump($as);

//file_put_contents('1.txt', json_encode($contents));

var_dump($contents);